function [ newRowPosition, newColPosition ] = getNewPosition( ImIn, lastPosition, window)
%Calculates new position based on the centroid of a window surrounding the 
%old position

 
    
    rowPosition = lastPosition(1);
    colPosition = lastPosition(2);
    
    for k = rowPosition - window: rowPosition + window
        for l = colPosition - window: colPosition + window
            rowDot = rowDot + k*imIn(k,l);
            colDot = colDot + l*imIn(k,l);
            sumIntensity = sumIntensity + A(k,l);
        end
    end
    newRowPosition = rowDot/SumIntensity;
    newColPosition = colDot/SumIntensity;
    
end

